﻿using System.Collections.ObjectModel;
using Heyo.Launcher.Models;
using HeyoUi.Models.Data.Game;
using HeyoUi.Util;
using Version = KMCCC.Launcher.Version;

namespace HeyoUi.Models
{
    public class GameListModel : Model
    {
        private GameListModel() { }
        public static GameListModel Instance { get; }
        static GameListModel()
        {
            Instance = new GameListModel();
            RefreshGameList();
            //foreach (Version ver in LauncherBasic.Versions)
            //{
            //    Instance.GameList.Add(new GameInfo(ver));
            //}
        }

        public static void RefreshGameList()
        {
            Instance.GameList.Clear();
            LauncherBasic.RefreshVersion();
            foreach (LocalGameInfo info in LauncherBasic.GameInfos)
            {
                Instance.GameList.Add(info);
            }
        }
        public ObservableCollection<LocalGameInfo> GameList { get; } = new ObservableCollection<LocalGameInfo>();


        public LocalGameInfo SelectedGameInfo
        {
            get => LauncherBasic.SelectedGame;
            set
            {
                LauncherBasic.SelectedGame = value;
                BmclGetter.GetForgeList(value.Version);
                //var t = DependenceInspector.Inspect(value);
                OnPropertyChanged();
            }
        }
    }
}
